﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using PreeRegisterModel;
using System.Collections.Specialized;
using PreeRegisterBLL;
using PreeRegisterBLL.Security;

namespace PreeRegister_WebAPI.Controllers
{
    public class securityController : ApiController
    {
        [HttpPost]
        /// <summary>
        /// 校验token
        /// </summary>
        /// <param name="any"></param>
        /// <returns></returns>
        public ReturnModel verifytoken(NameValueCollection any)
        {
            try
            {
                //获取JSON加密参数
                string head = CommonBLL.RequestGetParam("head").ToString();
                string method = CommonBLL.RequestGetParam("method").ToString();

                ReturnModel returnModel = new ReturnModel();

                string ErrMsg = "";

                if (ResultDecode.VerifyToken(head, method, ref ErrMsg))
                {
                    returnModel.code = "1";
                    returnModel.msg = ErrMsg;
                }
                else
                {
                    returnModel.code = "0";
                    returnModel.msg = "校验成功！";
                }

                return returnModel;
            }
            catch (Exception err)
            {
                ReturnModel returnModel = new ReturnModel();
                returnModel.code = "0";
                returnModel.msg = "token：" + err.Message;
                return returnModel;
            }
        }
    }
}
